/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package embeddedpaint.user_interface.tools.dialog;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.Observer;
import javax.swing.JFrame;

public class ToolFrame extends JFrame
{
    public static String G_UPDATE_KEY_VALUE_CHANGED = "G_UPDATE_KEY_VALUE_CHANGED";
    private ArrayList<Observer> m_listObserver;

    public ToolFrame()
    {
        this.setVisible(true);
        this.setEnabled(true);
        this.setAlwaysOnTop(true);
        this.setAutoRequestFocus(true);
        this.setResizable(false);
        
        this.m_listObserver = new ArrayList<>();
        
        this.addWindowListener(new WindowListener() 
        {
            @Override
            public void windowOpened(WindowEvent e)
            {
            }

            @Override
            public void windowClosing(WindowEvent e)
            {
                close();
            }

            @Override
            public void windowClosed(WindowEvent e)
            {
            }

            @Override
            public void windowIconified(WindowEvent e)
            {
            }

            @Override
            public void windowDeiconified(WindowEvent e)
            {
            }

            @Override
            public void windowActivated(WindowEvent e)
            {
            }

            @Override
            public void windowDeactivated(WindowEvent e)
            {
            }
        });
    }
    
    public void close ()
    {
    }
    
    public void addObserver (Observer observer)
    {
        this.m_listObserver.add(observer);
    }
    public void removeObserver (Observer observer)
    {
        this.m_listObserver.remove(observer);
    }

    public void updateObserver ()
    {
        for (Observer observer : m_listObserver)
        {
            observer.update(null, "");
        }
    }
    public void updateObserver (String key)
    {
        for (Observer observer : m_listObserver)
        {
            observer.update(null, key);
        }
    }
}
